package com.stox.shared.core.beans;

import com.stox.shared.core.util.Constant;


public class PropertyDescriptor extends AbstractDescriptor{

	private int index;
	private boolean hidden;
	private Object value;
	private String baseName;
	
	public PropertyDescriptor() {
		
	}

	public PropertyDescriptor(Class<?> type, Object value, String baseName, String displayName) {
		setType(type);
		setValue(value);
		setBaseName(baseName);
		setDisplayName(displayName);
	}
	
	public Object getValue() {
		return value;
	}
	
	public String getStringValue(){
		if(double.class.equals(getType()) || Double.class.equals(getType())){
			if(null == value){
				return Constant.numberFormat.format(0);
			}
			return Constant.numberFormat.format(Double.parseDouble(String.valueOf(value)));
		}else
			return String.valueOf(value);
	}
	
	public void setValue(Object value) {
		this.value = value;
	}

	public String getBaseName() {
		return baseName;
	}
	
	public void setBaseName(String baseName) {
		this.baseName = baseName;
	}
	
	public boolean isHidden() {
		return hidden;
	}
	
	public void setHidden(boolean hidden) {
		this.hidden = hidden;
	}
	
	public int getIndex() {
		return index;
	}
	
	public void setIndex(int index) {
		this.index = index;
	}
	
	@Override
	public String toString() {
		return "PropertyDescriptor [value=" + value + ", toString()="
				+ super.toString() + "]";
	}
	
}
